package com.example.administrator.waitan.mine.history;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.administrator.waitan.R;

import java.util.List;

/**
 * Created by Administrator on 2016/1/23.
 */
public class HistoryBaseAdapter extends BaseAdapter {
    private List<HistoryInfo> data;
    private Context context;

    public HistoryBaseAdapter(List<HistoryInfo> data, Context context) {
        this.data = data;
        this.context = context;
    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int i) {
        return data.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        MyViewHolder myViewHolder;
        if (view == null){
            view = LayoutInflater.from(context).inflate(R.layout.item_lv_history,null);
            myViewHolder = new MyViewHolder();
            myViewHolder.date = (TextView) view.findViewById(R.id.tv_item_history_date);
            myViewHolder.title = (TextView) view.findViewById(R.id.tv_item_history_title);
            view.setTag(myViewHolder);
        }
        else{
            myViewHolder = (MyViewHolder) view.getTag();
        }
        myViewHolder.date.setText(data.get(i).getDate());
        myViewHolder.title.setText(data.get(i).getTitle());
        return view;
    }
    class MyViewHolder{
        TextView day,date,title;
    }
}
